<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<p align="center" >
	<style="width:200px;">
</p>
<img id="pic" onclick="pos()" width="600" src="1.jpg" />

<script>
  var i = 1;
  var j = 1;
      function f(){
         i++;
         if(i==6)i = 1;
         pic.src=i+".jpg";
      }
      var timer = setInterval(f,1000);
      function pos(){
	if(j==1){
	   clearInterval(timer);
	   j = 0;
	}else{
	   timer = setInterval(f,1000);
	   j = 1;
	}
      }
</script>